package com.tgh.au.c5;

import java.util.concurrent.TimeUnit;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.MotionEvent;

public class Activity01 extends Activity {
    private GameView gameView;
    private static final int REFRESH=0X000001;
    
    private Handler handler=new Handler(){
    	public void handleMessage(Message msg) {
    		switch (msg.what) {
			case REFRESH:
				gameView.invalidate();
				break;
			}
    	}
    };
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gameView = new GameView(this);
        //setContentView(new GameSurface(this));
        //new Thread(new GameThread()).start();
        //setContentView(new GameView2(this));
        setContentView(new GameView9(this));
    }
	class GameThread implements Runnable{

		public void run() {
			while (!Thread.currentThread().isInterrupted()) {
				handler.sendEmptyMessage(REFRESH);
				try {
					TimeUnit.MILLISECONDS.sleep(100);
				} catch (Exception e) {
					Thread.currentThread().interrupt();
				}
				//这么处理，则不需要handler发送消息
				//gameView.postInvalidate();
			}
		}
	}
}